package cn.qzzg.controller;

import cn.qzzg.common.ResultBean;
import cn.qzzg.pojo.SamplesPersonnel;
import cn.qzzg.service.SamplesPersonnelService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/samplesPersonnel")
public class SamplesPersonnelController {
    @Resource
    SamplesPersonnelService samplesPersonnelService;

    /**
     * 查询所有
     */
    @RequestMapping(value = "/queryAll", method = RequestMethod.POST)
    public ResultBean<?> queryAll(@RequestBody String testTubeId) {
        testTubeId = testTubeId.replace("=", "");
        return ResultBean.success(samplesPersonnelService.findAllByTestTubeId(testTubeId));
    }


    /**
     * 创建
     *
     * @return true
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public ResultBean<?> create(@RequestBody SamplesPersonnel samplesPersonnel) {
        return ResultBean.success(samplesPersonnelService.saveOne(samplesPersonnel));
    }

    /**
     * 删除
     *
     * @param myObjet 需要删除的
     * @return true
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public ResultBean<?> delete(@RequestBody SamplesPersonnel myObjet) {
        return ResultBean.success(samplesPersonnelService.removeOneByIdCard(myObjet.getIdCard()));
    }
}
